import 'package:flutter/material.dart';
import 'package:online_study/theme/colors.dart';
import 'package:online_study/theme/size.dart';

//课程列表展示
class CourseItemPage extends StatefulWidget {
  bool hasTime = false;

  CourseItemPage(this.hasTime);

  @override
  _CourseItemPageState createState() => _CourseItemPageState(hasTime);
}

class _CourseItemPageState extends State<CourseItemPage> {
  bool hasTime = false;

  _CourseItemPageState(this.hasTime);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: ThemeSize.height96,
      alignment: Alignment.topLeft,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Container(
              margin: EdgeInsets.symmetric(vertical: ThemeSize.height8),
              width: ThemeSize.width110,
              height: ThemeSize.height80,
              decoration: BoxDecoration(
                  borderRadius:
                      BorderRadius.all(Radius.circular(ThemeSize.width9)),
                  image: DecorationImage(
                      image: NetworkImage(
                          "https://flutter.github.io/assets-for-api-docs/assets/widgets/puffin.jpg"),
                      fit: BoxFit.cover))),
          Expanded(
              child: Container(
            alignment: Alignment.centerLeft,
            padding: EdgeInsets.only(
                left: ThemeSize.height6, top: ThemeSize.height16),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text("员工日常行为规范",
                    style: TextStyle(
                        color: ThemeColor.color333333,
                        fontSize: ThemeSize.sp13,
                        fontWeight: FontWeight.bold)),
                Container(
                  padding: EdgeInsets.only(top: ThemeSize.height6),
                  child: Text("员工行为“十不准”",
                      style: TextStyle(
                          color: ThemeColor.color333333,
                          fontSize: ThemeSize.sp13)),
                ),
                Container(
                    padding: EdgeInsets.only(top: ThemeSize.height14),
                    child: _buildStudyInfo()),
              ],
            ),
          ))
        ],
      ),
    );
  }

  Widget _buildStudyInfo() {
    if (hasTime) {
      return Row(
        children: [
          Expanded(
              child: Text("已学习：1220人",
                  style: TextStyle(
                      color: ThemeColor.color555555,
                      fontSize: ThemeSize.sp10))),
          Text("2020-09-08 12:00",
              style: TextStyle(
                  color: ThemeColor.color555555, fontSize: ThemeSize.sp10))
        ],
      );
    }
    return Text("已学习：1220人",
        style:
            TextStyle(color: ThemeColor.color555555, fontSize: ThemeSize.sp10));
  }
}
